<?php

namespace app\model;

use app\BaseModel;
use think\model\relation\BelongsTo;

/**
 * 因子解释表
 */
class RatingScaleFactorLevelModel extends BaseModel
{
    protected $name = 'rating_scale_factor_level';

    /**
     * 新增数据验证
     * @return array
     */
    public function addValidate()
    {
        return [
            'rating_scale_id|量表id'  => 'require',
            'name|程度等级名称'  => 'require',
        ];
    }

    /**
     * 关联因子名
     * @return BelongsTo
     */
    public function factorName(): BelongsTo
    {
        return $this->belongsTo(RatingScaleFactorModel::class, 'factor_id')->bind([
            'factor_name' => 'name',
            'warning_method'
        ]);
    }

    /**
     * 关联因子表-是否为总分
     * @return BelongsTo
     */
    public function isTotal(): BelongsTo
    {
        return $this->belongsTo(RatingScaleFactorModel::class,'factor_id')->bind([
            'is_total'
        ]);
    }

}